home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: strncpy bug?
- Date: Fri, 29 Mar 96 23:20:35 GMT
- Organization: none
- Message-ID: <828141635snz@genesis.demon.co.uk>
- References: <ccurtis.826776589@ee.fit.edu> <4iffqt$gu4@hammy.lonestar.org>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4iffqt$gu4@hammy.lonestar.org>
- gordon@sneaky.lerctr.org "Gordon Burditt" writes:
-
- >There are a few ANSI C library functions that permit passing NULL
- >where a pointer is expected. Very few. If it's not documented
- >as OK, you invoke the wrath of undefined behavior. A NULL pointer
- >does not meet the definition of a "string". I think this is a complete
- >list of ANSI C functions that accept NULL pointers, but I might have
- >missed a couple:
- >
- >(FILE *) NULL
- > fflush(NULL) flushes all streams.
-
- Well, all streams for which fflush() is defined i.e. output streams and
- update streams where the last operation was a write.
-
- >(time_t *) NULL
- > time(NULL) doesn't store a copy through its first argument
- > in addition to the return value.
- >(void *) NULL
- > printf family, NULL argument matching a %p conversion may be printed.
-
- But make sure the argument you pass really is a (void *).
-
- > free(NULL) does nothing.
- > realloc(NULL, size) acts like malloc(size).
- >(char **) NULL
- > The 2nd argument of strtod, strtol, and strtoul may be NULL to
- > omit returning the pointer to the next character after the converted
- > number.
- >(char *) NULL (strings)
- > strtok (1st argument) NULL indicates continuing to use a
- > previously passed string.
- > strxfrm may have a NULL 1st argument if the length is 0.
- > system(NULL) is used to test whether the facility is available.
- >(char *) NULL (buffer)
- > setbuf and setvbuf(2nd argument) NULL indicates unbuffered operation.
-
- Only in setbuf(). In setvbuf() a NULL 2nd argument makes the function
- allocate a buffer internally (where appropriate).
-
- >(char *) NULL multibyte character functions
- > mblen (1st arg), mbtowc (2nd arg), and wctomb(1st arg) accept
- > NULL for certain special cases.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-